import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_styled_toast/flutter_styled_toast.dart';

class Setting extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Ddetails"),
      ),
      body: _Setting(),
    );
  }
}

class _Setting extends StatefulWidget {
  @override
  _MySeting createState() => _MySeting();
}

class _MySeting extends State<_Setting> {
  final TextEditingController _controller = TextEditingController();

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Text('设置'),
        FilledButton(
            onPressed: () {
              print("点击了");
              print('${_controller.text}');
              showToast("hello styled toast", context: context);
            },
            child: Text("Click Me")),
        ClipOval(
          child: FlutterLogo(
            size: 30,
          ),
        ),
        FloatingActionButton(
            //悬浮按钮
            child: FlutterLogo(
              size: 50,
            ),
            onPressed: () {
              print("click floating button");
              showDialog(
                  // 异步返回结果
                  context: context,
                  builder: (context) {
                    return AlertDialog(
                      title: Text("提示"),
                      content: Text("提示内容 提示内容?"),
                      actions: <Widget>[
                        TextButton(
                          child: Text("取消"),
                          onPressed: () {
                            print("点击了取消");
                          },
                          // onPressed: () => Navigator.of(context).pop(), //关闭对话框
                        ),
                        TextButton(
                          child: Text("确定"),
                          onPressed: () {
                            // ... 执行删除操作
                            // Navigator.of(context).pop(true); //关闭对话框
                            print("点击了确定");
                          },
                        ),
                      ],
                    );
                  });
            }),

        // GridView.builder(
        //   gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
        //     crossAxisSpacing: 10.0, //水平子 Widget 之间间距
        //     mainAxisSpacing: 10.0, //垂直子 Widget 之间间距
        //     crossAxisCount: 2,
        //   ),
        //   itemBuilder: (BuildContext context, int index) {
        //     Container(
        //       decoration: BoxDecoration(
        //           border: Border.all(
        //               color: const Color.fromRGBO(233, 233, 233, 0.9),
        //               width: 1)),
        //       child: Column(
        //         children: <Widget>[
        //           Image.asset('/assets/images/fen.png'),
        //           const SizedBox(height: 12),
        //           Text(
        //             "网格布局",
        //             textAlign: TextAlign.center,
        //             style: const TextStyle(fontSize: 20),
        //           )
        //         ],
        //       ),
        //       height: 400,
        //       //设置高度没有反应
        //     );
        //   },
        // ),
        //一行的 Widget 数量), itemBuilder: itemBuilder)

        Padding(
          padding: EdgeInsets.all(100.0),
          child: Text("padding设置了10"),
        ),
        InputChip(label: Text("Search")),
        Padding(
          padding: EdgeInsets.all(10),
          child: TextField(
            controller: _controller,
            textAlign: TextAlign.center,
            decoration: InputDecoration(
              hintText: '输入搜索内容',
              border: OutlineInputBorder(
                borderRadius: BorderRadius.circular(100),
              ),
              suffixIcon: IconButton(
                icon: Icon(Icons.clear),
                onPressed: () => _controller.clear(),
              ),
            ),
          ),
        )
      ],
    );
  }
}
